-
Notifications
You must be signed in to change notification settings - Fork 6.1k
executor: fix analyze cannot be killed #65249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
/retest |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #65249 +/- ##
================================================
+ Coverage 77.7736% 77.9980% +0.2243%
================================================
Files 2001 1922 -79
Lines 545596 533571 -12025
================================================
- Hits 424330 416175 -8155
+ Misses 119604 116954 -2650
+ Partials 1662 442 -1220
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest |
e93e052 to
253f0d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to make ANALYZE responsive to query kill/cancellation by propagating a SQLKiller-derived cancellation context into analyze workers and DistSQL/NextRaw paths, and adds a failpoint-based test to validate prompt exit on context cancellation.
Changes:
- Add a SQLKiller-provided cancelable context (
GetKillEventCtx) and propagate it through analyze execution paths. - Replace
context.TODO()with a propagated ctx in several analyze V1/V2 build/consume flows and add ctx-aware worker loops. - Add a failpoint-gated unit test ensuring
ANALYZEexits quickly after ctx cancellation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/util/sqlkiller/sqlkiller.go | Introduces kill-event context support for cancellation propagation. |
| pkg/util/sqlkiller/BUILD.bazel | Adds dependency needed for new sqlkiller error usage. |
| pkg/executor/analyze.go | Threads kill-derived ctx into analyze workers. |
| pkg/executor/analyze_col.go | Propagates ctx into analyze V1 build/NextRaw flow. |
| pkg/executor/analyze_col_v2.go | Adds ctx plumbing/cancellation to analyze V2 sampling workers and NextRaw usage. |
| pkg/executor/analyze_idx.go | Adds ctx parameters through index analyze call chain and cancellation checks. |
| pkg/distsql/distsql.go | Adds failpoint to block until ctx cancellation for testing. |
| pkg/executor/test/analyzetest/analyze_test.go | Adds unit test validating analyze cancellation behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
pkg/executor/analyze_col_v2.go
Outdated
| statsHandle.FinishAnalyzeJob(results.Job, nil, statistics.TableAnalysisJob) | ||
| totalResult.results[results.Ars[0].Hist[0].ID] = results | ||
| case <-ctx.Done(): | ||
| err = ctx.Err() |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On cancellation, this path sets err = ctx.Err(), which loses the cancellation cause from SQLKiller.GetKillEventCtx (set via cancelFn(errKilled)). Consider using context.Cause(ctx) (falling back to ctx.Err()) so the caller can differentiate SQL kill vs plain context cancellation.
| err = ctx.Err() | |
| err = context.Cause(ctx) | |
| if err == nil { | |
| err = ctx.Err() | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
ed61b41 to
cae7fa4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
|
/retest |
1 similar comment
|
/retest |
|
@hawkingrei: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/retest |
What problem does this PR solve?
Issue Number: close #65818
Problem Summary:
Analyze does not propagate cancellation context into RPC/NextRaw; killing the query can leave analyze workers blocked.
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.